package com.fss.mycomment1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.mycomment1.domain.Mycomment1;
import com.fss.mycomment1.service.IMycomment1Service;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * 评论Controller
 * 
 * @author llf
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/mycomment1/mycomment1")
public class Mycomment1Controller extends BaseController
{
    @Autowired
    private IMycomment1Service mycomment1Service;

    /**
     * 查询评论列表
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mycomment1 mycomment1)
    {
        startPage();
        List<Mycomment1> list = mycomment1Service.selectMycomment1List(mycomment1);
        return getDataTable(list);
    }

    /**
     * 导出评论列表
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:export')")
    @Log(title = "评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mycomment1 mycomment1)
    {
        List<Mycomment1> list = mycomment1Service.selectMycomment1List(mycomment1);
        ExcelUtil<Mycomment1> util = new ExcelUtil<Mycomment1>(Mycomment1.class);
        util.exportExcel(response, list, "评论数据");
    }

    /**
     * 获取评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mycomment1Service.selectMycomment1ById(id));
    }

    /**
     * 新增评论
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:add')")
    @Log(title = "评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mycomment1 mycomment1)
    {
        return toAjax(mycomment1Service.insertMycomment1(mycomment1));
    }

    /**
     * 修改评论
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:edit')")
    @Log(title = "评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mycomment1 mycomment1)
    {
        return toAjax(mycomment1Service.updateMycomment1(mycomment1));
    }

    /**
     * 删除评论
     */
    @PreAuthorize("@ss.hasPermi('mycomment1:mycomment1:remove')")
    @Log(title = "评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mycomment1Service.deleteMycomment1ByIds(ids));
    }
}
